﻿@model WeProjectsModel.Task
<style type="text/css">
    table tr td:first-child {
        width: 80px;
    }

    table td {
        padding-left: 10px;
        text-align: left !important;
    }
</style>

@{
    ViewBag.Title = "Details";
    int usrId=int.Parse(Membership.GetUser().ProviderUserKey.ToString());
}
@Html.Partial("../project/_projectMenu2")
<h2>@Html.DisplayFor(model => model.Project.Title) > 任务明细 </h2>  

    <table class="table">
        <tr>
            <td class="active">任务描述</td><td>@Html.DisplayFor(model => model.Description)</td>
        </tr>
        <tr>
            <td class="active">截止日期</td>
            <td>@Html.DisplayFor(model => model.Due)
            @if (Utility.IgnoreTime(DateTime.Now) > Utility.IgnoreTime((DateTime)Model.Due))
            {<b>已结束</b>}
            else
            { <b>进行中</b>}
            </td>
        </tr>
        <tr>
            <td class="active">参与人员</td>
            <td>@Html.DisplayFor(model => model.Responsibility)</td>
        </tr>
        <tr>
            <td class="active">说明</td>
            <td>@Html.DisplayFor(model => model.Comment)</td>
        </tr>
    </table>

@if (Utility.IgnoreTime(DateTime.Now) <= Utility.IgnoreTime((DateTime)Model.Due)||Model.Project.TaskDueTimeEnforcement==false) 
{
    if(Model.Project.ParentProject==null)
    { 
        <table class="table">
        @*@if (Model.Project.ParentID == null) { 
        <tr><td style="background-color: #dedede;width:130px">从子任务中选择：</td>
            <td>@using (Html.BeginForm("Files","Task",new{projectId = Model.ProjectID,taskId=Model.ID}, FormMethod.Post))
            {
                <input type="submit" name="Submit" id="Submit" value="从子任务中选择" />
            }</td>
        </tr>}*@
        <tr>
            <td style="background-color: #dedede;">上传文档：</td>
            <td>
            @using (Html.BeginForm("Upload", "Document", FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
                <p>
                    <input type="hidden" name="id" value=@Html.ViewContext.RouteData.Values["id"] />
                    @*<input type="hidden" name="project" value=@Model.ProjectID />*@
                    <input type="hidden" name="project" value=@ViewBag.ProjectID />
                    <input type="file" name="uploadFile" />
                    <input type="hidden" name="backURL" value="../Task/Details/" />
                    <input type="hidden" name="isTask" value="1" />
                    <input type="submit" name="Submit" id="Submit" value="上传" />
                </p>
            }
            </td>
        </tr>
        </table>
    }
}
<table class="table">
    <thead>文件列表</thead>
    <tr>
        <th></th><th>文件名</th><th>文件大小KB</th><th>所属项目</th><th>上传时间</th><th>上传人</th><th>操作</th>
    </tr>
    @{int rowNo=0;}
    @foreach (var item in Model.Documents)
    {
        <tr><td>
            @(++rowNo)
            </td>
            <td>@Html.DisplayFor(modelItem => item.Name)</td>
            <td>@Html.DisplayFor(modelItem => item.Size)</td>
            <td>@Html.DisplayFor(modelItem=>item.Project.Title)</td>
            <td>@Html.DisplayFor(modelItem => item.UploadDateTime)</td>
            <td>@Html.DisplayFor(modelItem => item.Member.DisplayName)</td>
            <td style="text-align:center !important">
                
                @Html.ActionLink("下载", "../Document/DownloadFile", new { file=item.ID,uploader=item.UploaderID }, new { @class = "btn btn-success btn-small" }) 
@if (DateTime.Now < Model.Due)
{
    if (item.UploaderID == usrId || Roles.IsUserInRole("sysadmin") || item.Project.OwnerID==usrId)
    {
                @*@Html.ActionLink("Edit", "../Document/Edit", new { id = item.ID })*@                
                @Html.ActionLink("删除", "DeleteDoc", new { docID = item.ID, taskID = Model.ID }, new { @class = "btn btn-danger btn-small" })
    }
}
            </td>
        </tr>
    }
    <tr><td colspan="7" style="text-align:center !important">总共 @rowNo 条记录</td></tr>
</table>

@*<p>
    @Html.ActionLink("Edit", "Edit", new { id=Model.ID }) |
    @Html.ActionLink("Back to List", "Index")
</p>*@
